package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class Test {
    public static void main(String[] args){
        try(
                Connection connection = DBUtil.getConnection();
                ) {
            Statement statement = connection.createStatement();
            String sql = "SELECT id,name,job,age FROM student WHERE class_id = 1";
            ResultSet rs = statement.executeQuery(sql);
            while(rs.next()){
                int id = rs.getInt("id");
                String name = rs.getString("name");
                String job = rs.getString("job");
                int age = rs.getInt("age");
                System.out.println(id+"--"+name+"--"+job+"--"+age);
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
